package Com.amit.synchronization;

class Customer
{
	int amount=10000;
	
	public synchronized void withdraw(int amount)
	
	{
		System.out.println("Going for deposite");
		if(this.amount<amount)
		{
			System.out.println("Less balance;waiting for deposite");
			try {
				wait();
			} catch (Exception e) {
				System.out.println(e);
				e.printStackTrace();
			}
			
		}
		
		this.amount-=amount;
		System.out.println("Witdraw is compled");
	}

	public synchronized void deposite(int amount) {
		System.out.println("Going to deposite");
		
		this.amount+=amount;
		System.out.println("Deposite is completed");
		notify();
		
	}
	
	
}

public class Lab4 {

	public static void main(String[] args) {
		
	final Customer c=new Customer();
	
	new Thread()
	{
		public void run()
		{
			c.withdraw(150000);
		}
	}.start();
	
	new Thread()
	{
		public void run()
		{
			c.deposite(10000);
		}
	}.start();
	
	
		
	}

}
